#! /usr/bin/env python
#
# Copyright (C) 2012, University of Osnabrueck
# Copyright (C) 2017-2019, Ing.-Buero Dr. Michael Lehning (www.lehning.de)
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#     # Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     # Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     # Neither the name of Osnabrueck University nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission.
#     # Neither the name of SICK AG nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission
#     # Neither the name of Ing.-Buero Dr. Michael Lehning nor the names of its
#       contributors may be used to endorse or promote products derived from
#       this software without specific prior written permission
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
#  Created on: 17.07.2012
#  Modified    2019 Nov 5th
#
#      Authors:  Michael Lehning <michael.lehning@lehning.de>
#                Martin Guenther <mguenthe@uos.de>
#
#
# Important: The min_ang and max_ang are relative to the x-axis of ROS. 
#            The coordinate system of ROS differs from the SICK coordinate system.
#        So be aware, if you compare the rviz output with the SOPAS ET output.
#            I.e. the Sopas-Y-Axis is the ROS-X-Axis.
#
#        This convention is consistent to the ROS coordinate convention
#
#            see: http://www.ros.org/reps/rep-0103.html#coordinate-frame-conventions
#
#               
#
PACKAGE='sick_scan_xd'
from dynamic_reconfigure.parameter_generator_catkin import *

from math import pi

gen = ParameterGenerator()
#       Name              Type      Reconfiguration level             Description                                    Default     Min         Max
gen.add("min_ang",        double_t, 0, "The angle of the first range measurement [rad].",                           -pi,-2*pi,2*pi)
gen.add("max_ang",        double_t, 0, "The angle of the last range measurement [rad].",                            pi,-2*pi,2*pi)
gen.add("intensity",      bool_t,   0, "Whether or not to return intensity values.    ",                              True)
gen.add("intensity_resolution_16bit",      bool_t,   0, "True = 16Bit False = 8Bit.    ",                              True)
gen.add("min_intensity",   double_t, 0, "Set range of LaserScan messages to infinity, if intensity < min_intensity", 0.0, 0.0, 65536.0)
gen.add("skip",           int_t,    0, "The number of scans to skip between each measured scan.",                     0,          0,         9)
gen.add("frame_id",       str_t,    0, "The TF frame in which laser scans will be returned.",                        "cloud")
gen.add("imu_frame_id",       str_t,    0, "The TF frame in which imu_data will be returned.",                        "imu_link")
gen.add("time_offset",    double_t, 0, "An offset to add to the time stamp before publication of a scan [s].",       -0.000,     -0.25, 0.25)
gen.add("sw_pll_only_publish",bool_t,0, "Publishes datagrams only if the software time synchronization is locked. This prevents leaps in the scan timestamps.")
gen.add("use_generation_timestamp",bool_t, 1, "Use the lidar generation timestamp (1) or send timestamp (0) for the software pll converted message timestamp.")
gen.add("auto_reboot",    bool_t,   0, "Whether or not to reboot laser if it reports an error.",                      True)
gen.add("filter_echos", int_t,  0, "Bitmask to filter first [0], all [1], or last echos [2]", 2, 0, 2)
gen.add("powerOnCount", int_t   ,0, "Read only Power On counter at start up.",                            0,0,65536)
gen.add("operationHours", double_t  ,0, "Read only operationg hours [h].",                            0,0,6553.6)
gen.add("locationName", str_t,0, "Device Location Name",""),
gen.add("timelimit", double_t, 0, "Network time limit for datagram request [sec].",                             5.0, 0.1,100.0)
gen.add("cloud_output_mode", int_t, 0, "[0] Pointcloud is dense all layers in one cloud,[1] Each layer in its own cloud message to improve timestamp accuracy,[2] layers are split to achieve approx. 1 KHz data rate",                            0,0,2)
gen.add("ang_res",      double_t, 0, "Angular resolution in deg/scan set to 0 to use scanner default",  0 ,0,10)
gen.add("scan_freq",    double_t, 0, "Scan frequency set to 0 to use scanner default", 0, 0, 150)
gen.add("encoder_mode", int_t, 0, "-1:No Encoder, 0:Off, 1:Single increment, 2:Direction Phase, 3:Direction Level",-1 ,-1, 4)
gen.add("scan_cfg_list_entry",  int_t, 0, "scan config for | LRS 3601 3611 |OEM 1501|NAV 310 |LRS 3600 3610 4000 |OEM 1500|",-1 ,1,71) # LD Series switching table: 1-46, LRS4000 switching table: 1-71
# gen.add("mean_filter", int_t,  0, "Number of averages for mean filter 0 means filter is disabled", 0, 0, 100)
# gen.add("mirror_scan",bool_t, 0, "Scan direction's changed. E.g. for overhead mounting or NAV 310 ( in contrast to other sick scanners NAV 310 is clockwise rotating ).",False)
# gen.add("use_safety_fields",    bool_t,   0, "Whether or not to use safety fields. Only tim 7xxS supported at the moment", False) # True)
exit(gen.generate(PACKAGE, "sick_scan_xd", "SickScan"))
